package com.iron.sfm.biz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iron.common.core.util.R;
import com.iron.sfm.api.entity.TxB;
import com.iron.sfm.biz.service.TxBService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 
 *
 * @author yt
 * @date 2019-07-16 17:08:15
 */
@RestController
@AllArgsConstructor
@RequestMapping("/txb")
public class TxBController {

  private final TxBService txBService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param txB 
   * @return
   */
  @GetMapping("/page")
  public R getTxBPage(Page page, TxB txB) {
    return  R.ok(txBService.page(page,Wrappers.query(txB)));
  }


  /**
   * 通过id查询
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") String id){
    return R.ok(txBService.getById(id));
  }

  /**
   * 新增
   * @param txB 
   * @return R
   */
  @PostMapping("/save")
  public R save(@RequestBody TxB txB){
    return R.ok(txBService.saveTxB(txB));
  }

  /**
   * 修改
   * @param txB 
   * @return R
   */
  @PutMapping
  public R updateById(@RequestBody TxB txB){
    return R.ok(txBService.updateById(txB));
  }

  /**
   * 通过id删除
   * @param id id
   * @return R
   */
  @DeleteMapping("/{id}")
  public R removeById(@PathVariable String id){
    return R.ok(txBService.removeById(id));
  }

}
